package com.yikaiye.android.yikaiye.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.DataBindingHolder;
import com.yikaiye.android.yikaiye.R;
import com.yikaiye.android.yikaiye.databinding.ItemServiceAttrBinding;

public class AttrAdapter extends BaseQuickAdapter<String, DataBindingHolder<ItemServiceAttrBinding>> {

    @Override
    protected void onBindViewHolder(@NonNull DataBindingHolder<ItemServiceAttrBinding> itemServiceAttrBindingDataBindingHolder, int i, @Nullable String s) {
        ItemServiceAttrBinding binding = itemServiceAttrBindingDataBindingHolder.getBinding();
        binding.nameTv.setText(s);
        binding.line.setVisibility(i == getItemCount() - 1 ? View.GONE : View.VISIBLE);
    }

    @NonNull
    @Override
    protected DataBindingHolder<ItemServiceAttrBinding> onCreateViewHolder(@NonNull Context context, @NonNull ViewGroup viewGroup, int i) {
        return new DataBindingHolder<>(R.layout.item_service_attr, viewGroup);
    }
}
